#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

struct s1{
    char c1;
    int i;
    char c2;
};
struct s2{
    char c1;
    char c2;
    int i;
};
void test1(){
    cout << offsetof(struct s2,c1) << endl;
    cout << offsetof(struct s2,c2) << endl;
    cout << offsetof(struct s2,i) << endl;
    cout << sizeof(struct s1) << endl;
    cout << sizeof(struct s2) << endl;
    cout << sizeof(double) << endl;
}

void test2(){
    char p1[15] = "abcd", *p2 = "ABCD", str[50] = "xyz";
    strcat(p1+4,p2+1);
    printf("%s\n",p1);
    //cout << p1 << endl;
    strcpy(str+2, strcat(p1+2,p2+1));
    cout << str << endl;
}

char fun(char x, char y){
    if (x < y)
        return x;
    return y;
}

void test3(){
    int a = '1';
    int b = '1';
    int c = '2';
    cout << fun(fun(a,b), fun(b,c));
}

void test4(){
    char dog[] = "wang\0miao";
    cout << sizeof(dog) << endl;
    cout << strlen(dog) << endl;
}

void test5(){
    int n[][3] = {10,20,30,40,50,60};
    int (*p)[3];
    p = n;
    cout << p[0][0] << *(p[0]+1) << *(p[0]+2);
}

bool isCircle(const string& s){
    int begin = 0;
    int end = s.size() - 1;
    while (begin < end){
        if(s[begin] != s[end])
            return false;
        ++begin;
        --end;
    }
    return true;
}

void Test1(){
    string a, b;
    getline(cin,a);
    getline(cin,b);
    int count = 0;
    for (int i = 0; i <= a.size(); ++i) {
        string tmp = a;
        tmp.insert(i,b);
        if (isCircle(tmp))
            ++count;
    }
    cout << count << endl;
}

long get_max(long a, long b){
    return a > b ? a : b;
}

void Test2(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    long max_sum = arr[0];
    long sum = arr[0];
    for (int i = 1; i < n; ++i) {
        sum = get_max(arr[i],sum+arr[i]);
        if (sum > max_sum)
            max_sum = sum;
    }
    cout << max_sum << endl;
}

